/**
 * Created by muyonghui on 17/3/8.
 */
var oracledbUtil = require("../utils/oracledbUtil").oracledbUtil;
var async = require("async");

var OracleJSXXBEntity = require("../models/OracleJSXXB").OracleJSXXBEntity;



function updateJSXXB() {
    oracledbUtil("SELECT * FROM MZKT_JSXXB ",
        [],  function (err, result) {
            if (err){
                console.log(err);
                return;
            }

            if (result){
                async.each(result.rows,function (teacher, teacherCallback) {
                    OracleJSXXBEntity.findOneAndUpdate({ zgh:teacher[0]},{$set:{
                        zgh:teacher[0],
                        xm:teacher[1],
                        bm:teacher[2]
                    }},{upsert:true,new:true},function (err, doc) {
                        if (err){
                            teacherCallback(err);
                            return ;
                        }
                        console.log(doc.zgh +"更新成功");
                        teacherCallback();
                    })
                },function (err) {
                    if(err){
                        console.log(err);
                    }else{
                        console.log("更新完成");
                    }
                })

            }

        })

}
